<template>
  <div id="register">
      <el-form ref="registerForm" :model="user" label-width="80px">
        <el-form-item label="姓名">
          <el-input v-model="user.username" style="color: black"></el-input>
        </el-form-item>
        <el-form-item label="账号">
          <el-input v-model="user.userAccount"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="registerSubmit">立即创建</el-button>
          <el-button @click="registerFormVisible=false">取消</el-button>
        </el-form-item>
      </el-form>
  </div>
</template>

<script>
    export default {
        name: "Register",
        data(){
          return {
            user:{
              username:"",
              userAccount:""
            },
          }
        },
        methods:{
          registerSubmit(){
            this.loading = true
            this.$store.dispatch('user/register', this.user).then(()=>{//注册成功
              this.$message("注册成功",{
                type:"success"
              })
              this.registerFormVisible = false;
              this.loading = false;
            }).catch(()=>{//注册失败
              this.loading = false;
            })
          },
        }
    }
</script>

<style lang="scss" scoped>
  .el-form-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 1);
    border-radius: 5px;
    color: #454545;
  }
</style>
